import * as React from "react";
import { Navigate, Outlet } from "react-router-dom";
import TabBottom from "../components/TabBottom";
import { useLocation } from "react-router-dom";
import { useUserStore } from "../store/user";
import { useNavigate } from "react-router-dom";
export interface IMainProps {}

export default function Main(props: IMainProps) {
  const { pathname } = useLocation();
  const { userInfo } = useUserStore((state) => state);
  const navigate = useNavigate();
  // const guard = () => {
  //   // 访问的路径
  //   // 登录状态
  //   if (pathname.indexOf("mine") != -1) {
  //     return userInfo ? <Outlet /> : navigate("/login");
  //   } else {
  //     return <Outlet />;
  //   }
  // };
  // React.useEffect(() => {
  //   console.log("main的useEffect");
  //   if (pathname.indexOf("mine") != -1 && !userInfo) {
  //     navigate("/login");
  //   }
  // }, [pathname]);
  return (
    <div>
      <Outlet />
      {/* {guard()} */}
      <TabBottom />
    </div>
  );
}
